/*
 * MemoryComment.java
 *
 * Created on August 3, 2004, 8:10 AM
 */

package org.infoset.xml.memory;

import java.util.*;
import org.infoset.xml.*;
import org.infoset.xml.util.*;

/**
 *
 * @author  R. Alexander Milowski
 */
public class MemoryComment extends MemoryTextDataItem implements Comment {

   int index;
   int line;
   int column;
   /** Creates a new instance of MemoryComment */
   public MemoryComment(Infoset infoset,Parent origin,String textValue) {
      super(infoset,origin);
      setText(textValue);
      this.line = line;
      this.column = column;
   }
   
   public Item copyOfItem(boolean copyAll) {
      return new MemoryComment(infoset,null,value);
   }
   
   public ItemType getType() {
      return ItemType.CommentItem;
   }
   
   protected void setIndex(int i) {
      this.index = i;
   }
   
   public int getColumn() {
      return column;
   }   

   public int getLine() {
      return line;
   }
   
   public void setColumn(int column) {
      this.column = column;
   }
   
   public void setLine(int line) {
      this.line = line;
   }
   
   public Parent getParent() {
      return getOrigin();
   }
   
   public Child getFollowingSibling() {
      return (Child)origin.get(index+1);
   }

   public Child getPrecedingSibling() {
      return (Child)origin.get(index-1);
   }
   
   public Iterator getFollowingSiblings() {
      return new SiblingIterator(getFollowingSibling(),true);
   }
   
   public Iterator getPrecedingSiblings() {
      return new SiblingIterator(getPrecedingSibling(),false);
   }
   
   public Object clone() {
      MemoryComment child = new MemoryComment(infoset,getParent(), value);
      child.setIndex(index);
      return child;
   }
}
